home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / dbms_mag / 9103 / yellick3.mar < prev   
Text File  |  1991-02-04  |  1KB  |  45 lines

  1. Listing 3: Directory.ch
  2.  
  3. #include "DIRECTRY.CH"
  4. function LoadDir(path)
  5. /*
  6.     Return array containing entire directory structure of drive
  7.      volume. This function uses a recursive call to itself.
  8. */
  9.      local i, name, d_
  10.      local r_ := {}
  11.      
  12.      if path = nil
  13.          path := "\"
  14.      endif
  15.  
  16.      //  Load contents of the specified directory path,
  17.      //  including any subdirectory entries that might be there. 
  18.      d_ := directory(path +"*.*", "D")
  19.      
  20.      //  Loop once for each entry in directory.
  21.      for i := 1 to len(d_)
  22.        name := d_[i, F_NAME]
  23.      
  24.        //  If the file attribute indicates this
  25.        //  is a subdirectory entry, special handling is needed. 
  26.        if d_[i, F_ATTR] = "D"
  27.      
  28.        //  Skip the "." and ".." entries.
  29.           if .not. (name $ "..")
  30.      
  31.          //  Add the subdirectory name to the array
  32.          //  and call the directory loader function to
  33.          //  return the array of file names.
  34.               aadd(r_, {name, LoadDir(path +name +"\")})
  35.         endif
  36.      
  37.           //  If the file isn't a subdirectory name,
  38.           //  add it to the array of file names.
  39.           else
  40.               aadd(r_, name)
  41.            endif
  42.        next i
  43.      
  44.      return r_
  45.